CC = /usr/bin/g++
CPPFLAGS = -g -c -O2 -Wall -Wno-unused -fexceptions -D__OMNIORB4__ -D_REENTRANT -D__OSVERSION__=2 -D__linux__ -D__x86_64

LDFLAGS = -g -O2 -Wall -Wno-unused -fexceptions -D__OMNIORB4__ -D_REENTRANT -D__OSVERSION__=2 -D__linux__ -D__x86_64

OMNIIDL = /usr/bin/omniidl

GTKLIBS = `pkg-config gtkmm-2.4 libglademm-2.4 --cflags --libs`

LIBS = -lomniORB4 -lomnithread -lomniDynamic4 $(GTKLIBS)

OBJECTS = listenerSK.o listenerDynSK.o config.o window.o clock.o listener_impl.o delivery.o recv.o send.o

all: $(OBJECTS)
	$(CC) $(LDFLAGS) -o vector_clock main.cc $(OBJECTS) $(LIBS)

listenerSK.o: listenerSK.cc listener.hh
	$(CC) $(CPPFLAGS) listenerSK.cc

listenerDynSK.o: listenerDynSK.cc listener.hh
	$(CC) $(CPPFLAGS) listenerDynSK.cc

config.o: config.cc config.h
	$(CC) $(CPPFLAGS) config.cc

window.o: window.cc window.h
	$(CC) $(CPPFLAGS) $(GTKLIBS) window.cc

clock.o: clock.cc clock.h
	$(CC) $(CPPFLAGS) clock.cc

listener_impl.o: listener_impl.cc listener_impl.h
	$(CC) $(CPPFLAGS) $(GTKLIBS) listener_impl.cc

delivery.o: delivery.cc delivery.h
	$(CC) $(CPPFLAGS) $(GTKLIBS) delivery.cc

recv.o: recv.cc recv.h
	$(CC) $(CPPFLAGS) recv.cc

send.o: send.cc send.h
	$(CC) $(CPPFLAGS) $(GTKLIBS) send.cc

listenerSK.cc: listener.idl
	$(OMNIIDL) -bcxx -Wba listener.idl

clean:
	rm -rf *.o
	rm -rf *.hh
	rm -rf *SK.cc
	rm -rf vector_clock
